using System;
using System.Data;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using PointOfSale.Global; 
namespace PointOfSale.Report.Sale
{
	/// <summary>
	/// Summary description for POSPurchaseItemDetailsReport.
	/// </summary>
	public class frmReportCriteria : System.Windows.Forms.Form
	{
		private System.Windows.Forms.GroupBox groupBox1;
		private System.Windows.Forms.Button btnReport;
		private System.Windows.Forms.Button btnClose;
		private System.Windows.Forms.Label label1;
		private System.Windows.Forms.Label label2;
		private System.Windows.Forms.PictureBox pictureBox1;
		public static  string dTuNgay;
		public static  string dDenNgay;
		private System.Windows.Forms.DateTimePicker dtpToDate;
		private System.Windows.Forms.DateTimePicker dtpFromDate;
		private System.Windows.Forms.Label label3;
		private System.Windows.Forms.ComboBox cboCate;
		private DataSet ds=new DataSet();

		/// <summary>
		/// Required designer variable.
		/// </summary>
		private System.ComponentModel.Container components = null;

		public frmReportCriteria()
		{
			//
			// Required for Windows Form Designer support
			//
			InitializeComponent();

			//
			// TODO: Add any constructor code after InitializeComponent call
			//
		}

		/// <summary>
		/// Clean up any resources being used.
		/// </summary>
		protected override void Dispose( bool disposing )
		{
			if( disposing )
			{
				if(components != null)
				{
					components.Dispose();
				}
			}
			base.Dispose( disposing );
		}

		#region Windows Form Designer generated code
		/// <summary>
		/// Required method for Designer support - do not modify
		/// the contents of this method with the code editor.
		/// </summary>
		private void InitializeComponent()
		{
			System.Resources.ResourceManager resources = new System.Resources.ResourceManager(typeof(frmReportCriteria));
			this.groupBox1 = new System.Windows.Forms.GroupBox();
			this.cboCate = new System.Windows.Forms.ComboBox();
			this.label3 = new System.Windows.Forms.Label();
			this.label2 = new System.Windows.Forms.Label();
			this.label1 = new System.Windows.Forms.Label();
			this.dtpToDate = new System.Windows.Forms.DateTimePicker();
			this.dtpFromDate = new System.Windows.Forms.DateTimePicker();
			this.btnReport = new System.Windows.Forms.Button();
			this.btnClose = new System.Windows.Forms.Button();
			this.pictureBox1 = new System.Windows.Forms.PictureBox();
			this.groupBox1.SuspendLayout();
			this.SuspendLayout();
			// 
			// groupBox1
			// 
			this.groupBox1.Controls.Add(this.cboCate);
			this.groupBox1.Controls.Add(this.label3);
			this.groupBox1.Controls.Add(this.label2);
			this.groupBox1.Controls.Add(this.label1);
			this.groupBox1.Controls.Add(this.dtpToDate);
			this.groupBox1.Controls.Add(this.dtpFromDate);
			this.groupBox1.FlatStyle = System.Windows.Forms.FlatStyle.System;
			this.groupBox1.Location = new System.Drawing.Point(112, 8);
			this.groupBox1.Name = "groupBox1";
			this.groupBox1.Size = new System.Drawing.Size(200, 128);
			this.groupBox1.TabIndex = 0;
			this.groupBox1.TabStop = false;
			this.groupBox1.Text = "Select Dates";
			// 
			// cboCate
			// 
			this.cboCate.Location = new System.Drawing.Point(96, 88);
			this.cboCate.Name = "cboCate";
			this.cboCate.Size = new System.Drawing.Size(88, 21);
			this.cboCate.TabIndex = 5;
			this.cboCate.Text = "All";
			// 
			// label3
			// 
			this.label3.Location = new System.Drawing.Point(24, 96);
			this.label3.Name = "label3";
			this.label3.Size = new System.Drawing.Size(64, 16);
			this.label3.TabIndex = 4;
			this.label3.Text = "Department";
			// 
			// label2
			// 
			this.label2.Location = new System.Drawing.Point(24, 64);
			this.label2.Name = "label2";
			this.label2.Size = new System.Drawing.Size(48, 16);
			this.label2.TabIndex = 3;
			this.label2.Text = "To Date";
			// 
			// label1
			// 
			this.label1.Location = new System.Drawing.Point(24, 32);
			this.label1.Name = "label1";
			this.label1.Size = new System.Drawing.Size(64, 16);
			this.label1.TabIndex = 2;
			this.label1.Text = "From Date";
			// 
			// dtpToDate
			// 
			this.dtpToDate.Format = System.Windows.Forms.DateTimePickerFormat.Short;
			this.dtpToDate.Location = new System.Drawing.Point(96, 56);
			this.dtpToDate.Name = "dtpToDate";
			this.dtpToDate.Size = new System.Drawing.Size(88, 20);
			this.dtpToDate.TabIndex = 1;
			// 
			// dtpFromDate
			// 
			this.dtpFromDate.Format = System.Windows.Forms.DateTimePickerFormat.Short;
			this.dtpFromDate.Location = new System.Drawing.Point(96, 32);
			this.dtpFromDate.Name = "dtpFromDate";
			this.dtpFromDate.Size = new System.Drawing.Size(88, 20);
			this.dtpFromDate.TabIndex = 0;
			this.dtpFromDate.Value = new System.DateTime(2005, 9, 18, 0, 0, 0, 0);
			// 
			// btnReport
			// 
			this.btnReport.FlatStyle = System.Windows.Forms.FlatStyle.System;
			this.btnReport.Location = new System.Drawing.Point(152, 144);
			this.btnReport.Name = "btnReport";
			this.btnReport.TabIndex = 1;
			this.btnReport.Text = "Report";
			this.btnReport.Click += new System.EventHandler(this.btnReport_Click);
			// 
			// btnClose
			// 
			this.btnClose.FlatStyle = System.Windows.Forms.FlatStyle.System;
			this.btnClose.Location = new System.Drawing.Point(232, 144);
			this.btnClose.Name = "btnClose";
			this.btnClose.TabIndex = 2;
			this.btnClose.Text = "Close";
			this.btnClose.Click += new System.EventHandler(this.btnClose_Click);
			// 
			// pictureBox1
			// 
			this.pictureBox1.Image = ((System.Drawing.Image)(resources.GetObject("pictureBox1.Image")));
			this.pictureBox1.Location = new System.Drawing.Point(8, 16);
			this.pictureBox1.Name = "pictureBox1";
			this.pictureBox1.Size = new System.Drawing.Size(104, 96);
			this.pictureBox1.TabIndex = 4;
			this.pictureBox1.TabStop = false;
			// 
			// frmPOSPurchaseItemDetailsReport
			// 
			this.AutoScaleBaseSize = new System.Drawing.Size(5, 13);
			this.ClientSize = new System.Drawing.Size(320, 180);
			this.Controls.Add(this.btnClose);
			this.Controls.Add(this.btnReport);
			this.Controls.Add(this.groupBox1);
			this.Controls.Add(this.pictureBox1);
			this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.Fixed3D;
			this.MaximizeBox = false;
			this.MinimizeBox = false;
			this.Name = "frmPOSPurchaseItemDetailsReport";
			this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
			this.Text = "POS Purchase Item Details Report";
			this.Load += new System.EventHandler(this.frmPOSPurchaseItemDetailsReport_Load);
			this.groupBox1.ResumeLayout(false);
			this.ResumeLayout(false);

		}
		#endregion

		private void frmPOSPurchaseItemDetailsReport_Load(object sender, System.EventArgs e)
		{
			int i=0;
			dtpFromDate.MaxDate=System.Convert.ToDateTime("1/1/2006");
			dtpToDate.MaxDate=System.Convert.ToDateTime("1/1/2006");
			ds=clsGlobal.Db.GetDataToDataSet("select DepartmentName from tblDepartment",clsGlobal.g_DataConn,"tblDepartment");
			if(ds.Tables["tblDepartment"].Rows.Count>0)
			{
				for(i=0;i<ds.Tables["tblDepartment"].Rows.Count;i++)
				{
					string ItemName=ds.Tables["tblDepartment"].Rows[i]["DepartmentName"].ToString().Trim();
					cboCate.Items.Add(ItemName);
				}
			cboCate.Items.Add("All");
			}
		}

		private void btnReport_Click(object sender, System.EventArgs e)
		{
			if(dtpFromDate.Value>dtpToDate.Value)
			{
				MessageBox.Show("Invalid date","Alert",MessageBoxButtons.OK);
			}
			else
			{
				DateTime dFromDate = dtpFromDate.Value;
				DateTime dToDate = dtpToDate.Value;
				string strDepartment = cboCate.Text;
				//frmReportSaleTransaction _test=new frmReportSaleTransaction(dFromDate, dToDate, strDepartment);
				//_test.Show();
				this.Dispose();
			}

		}

		private void btnClose_Click(object sender, System.EventArgs e)
		{
			this.Dispose();
		}
	}
}
